package com.glsc.ngateway.common.base.domain.mysql.opmanagemain.outsys;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.glsc.ngateway.common.api.common.enums.DictConstant;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author liwei
 * 外部系统权限信息表
 */
@Data
@Entity
@Table(name = "t_out_system_auth_info")
@org.hibernate.annotations.Table(appliesTo = "t_out_system_auth_info", comment = "外部系统权限信息表")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Where(clause = "deleted = 'N'")
public class OutSystemAuthInfo implements Serializable {

    private static final long serialVersionUID = -9166019246262366062L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    @Column(name = "system_name", columnDefinition = "varchar(100) COMMENT '系统名称'")
    @ApiModelProperty(value = "系统名称")
    private String systemName;

    @Column(name = "sys_id", columnDefinition = "INT COMMENT '系统id'")
    @ApiModelProperty(value = "系统id")
    private Integer sysId;

    @Column(name = "auth_name1", columnDefinition = "varchar(200) COMMENT '一级权限名称'")
    @ApiModelProperty(value = "一级权限名称")
    private String authName1;

    @Column(name = "auth_name2", columnDefinition = "varchar(200) COMMENT '二级权限名称'")
    @ApiModelProperty(value = "二级权限名称")
    private String authName2;

    @Column(name = "auth_name3", columnDefinition = "varchar(200) COMMENT '三级权限名称'")
    @ApiModelProperty(value = "三级权限名称")
    private String authName3;

    @Column(name = "auth_name4", columnDefinition = "varchar(200) COMMENT '四级权限名称'")
    @ApiModelProperty(value = "四级权限名称")
    private String authName4;

    @Column(name = "auth_name5", columnDefinition = "varchar(200) COMMENT '五级权限名称'")
    @ApiModelProperty(value = "五级权限名称")
    private String authName5;

    @Column(name = "user_name", columnDefinition = "varchar(200) COMMENT '用户名称'")
    @ApiModelProperty(value = "用户名称")
    private String userName;

    @Column(name = "user_account", columnDefinition = "varchar(200) COMMENT '用户账号'")
    @ApiModelProperty(value = "用户账号")
    private String userAccount;

    @Column(name = "dept_name", columnDefinition = "varchar(400) COMMENT '部门名称'")
    @ApiModelProperty(value = "部门名称")
    private String deptName;

    @Column(name = "dept_id", columnDefinition = "INT COMMENT '部门id'")
    @ApiModelProperty(value = "部门id")
    private Integer deptId;

    @Column(name = "post_name", columnDefinition = "varchar(200) COMMENT '岗位名称'")
    @ApiModelProperty(value = "岗位名称")
    private String postName;

    @Column(name = "operator_name", columnDefinition = "varchar(200) COMMENT '权限操作人名称'")
    @ApiModelProperty(value = "权限操作人名称")
    private String operatorName;

    @Column(name = "user_id", columnDefinition = "INT COMMENT '用户id'")
    @ApiModelProperty(value = "用户id")
    private Integer userId;

    @ApiModelProperty(value = "是否删除，字典 YesNo:（N=未删除(默认) Y=已删除)")
    @Column(name = "deleted", columnDefinition = "varchar(20) default 'N' COMMENT '是否删除，字典 yesno （N=否(默认) Y=是)'")
    private String deleted = DictConstant.NO;

    @ApiModelProperty(value = "是否启用，字典 YesNo:（N=禁用 Y=启用)")
    @Column(name = "enable", columnDefinition = "varchar(20) default 'N' COMMENT '是否启用，字典 YesNo:（N=禁用 Y=启用)'")
    private String enable = DictConstant.YES;


    //创建时间
    @Column(name = "create_time", updatable = false)
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "操作人员ID")
    @Column(name = "op_operator", columnDefinition = "varchar(20) COMMENT '操作人员ID'")
    private String opOperator;

    @ApiModelProperty(value = "操作时间 yyyy-MM-dd HH:mm:ss")
    @Column(name = "op_time", columnDefinition = "datetime comment '操作时间'")
    @org.hibernate.annotations.UpdateTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime opTime;

}
